package service.impl;

import entity.Patient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import repository.PatientRepository;
import service.PatientService;

import java.util.List;

@Service
public class PatientServiceImpl implements PatientService {

    @Autowired
    private PatientRepository patientRepository;

    public Integer save(Object o) {
        Patient patient = (Patient) o;
        return patientRepository.save(patient);
    }

    public List<Patient> findAll() {
        return patientRepository.findAll();
    }

    public void delete(Integer id) {
        patientRepository.delete(id);
    }

    public Integer update(Object o) {
        Patient patient = (Patient) o;
        patientRepository.saveOrUpdate(patient);
        return patient.getId();
    }
}
